<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp" %>
<title>登陆界面</title>
</head>
<body>

<div class='window'>
<fieldset class="layui-elem-field" style="margin:10px">
<legend>登录</legend>

<div class="layui-filed-box">
<form class="layui-form layui-form-pane" method="post">

<div class="layui-form-item">
<lable class="layui-form-label">用户名：</lable>
<div class="layui-input-inline">
<input type="text" name='code' placeholder="请输入用户名" class='layui-input'>
</div>
</div>

<div class="layui-form-item">
<lable class="layui-form-label">密码：</lable>
<div class="layui-input-inline">
<input type="text" name='pass' placeholder="请输入密码" class='layui-input'>
</div>
</div>

<div class="layui-form-item">
<div class="layui-input-inline">
<input type="button"  value='登录' class='layui-btn' lay-submit lay-filter='login'>
<input type='reset' value='重置' class='layui-btn layui-btn-primary'>
</div>
<input type='button' value='注册' class='layui-btn' onclick='toReg()'>
</div>

<input type='hidden' name='action' value='login'>

</form>
</div>
</fieldset>
</div>

<script type="text/javascript">
var form=layui.form, $=layui.jquery, layer=layui.layer
form.on("submit(login)",function(data){
	$.ajax({
		url:base.app+"/employee",
		data:data.field,
		type:"post",
		dataType:"text",
// 回调函数,请求成功后根据返回回来的数据进行判断
		success:function(data){  
			if(data==1){
				
// 				layer.msg("登陆成功")
// 				location.href=base.app+'/web/page/main.jsp'
				layer.msg("登陆成功",function(){
					location.href=base.app+'/web/page/main.jsp'
				})
			}else if(data==2){
				layer.msg("密码错误")
			}else if(data==0){
				layer.msg("账号错误")
			}
		}
	})
})

function toReg(){
	location.href=base.app+'/web/reg.jsp'
} 
</script>
</body>
</html>